<style lang="less">
@import "./login.less";
</style>

<template>
  <div class="login-wrap">
    <div class="login">
      <div class="login-con">
        <Card icon="log-in"
              style="background: #81beff;"
              title="清慈客户管理系统登录"
              :bordered="false">
          <div class="form-con">
            <login-form @on-success-valid="handleSubmit"
                        :loading='loading'></login-form>
          </div>
        </Card>
      </div>
    </div>
  </div>

</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  data () {
    return {
      loading: false
    }
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo',
      'setStoreList'
    ]),
    handleSubmit ({ userName, password }) {
      this.loading = true
      this.handleLogin({
        account: userName,
        pwd: password
      }).then(res => {
        this.setStoreList().then(res => {
          this.$router.push({
            name: this.$config.homeName
          })
        })
      }).catch(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style>
</style>
